package com.itheima_32;

import java.util.Calendar;

public class CalendarDemo {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance(); // 多态的形式
        System.out.println(c);



        c.add(Calendar.YEAR, -3);
        System.out.println(c.get(Calendar.YEAR));
        c.add(Calendar.MONTH, -1);
        System.out.println(c.get(Calendar.MONTH));

        c.set(2018, 11, 11);
        printDate(c);

    }

    public static void printDate(Calendar c) {
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH) + 1;
        int day = c.get(Calendar.DATE);

        System.out.println(year + "-" + month + "-" + day);
    }
}
